#pragma once

#pragma warning( disable: 4640 ) // 'instance' : construction of local static object is not thread-safe
#pragma warning( disable: 4711 ) // function 'function' selected for inline expansion
#pragma warning( disable: 4820 ) // 'identifier' : 'bytes' bytes padding added after construct 'member_name'

#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
#define _ATL_FREE_THREADED
#define  ATL_NO_ASSERT_ON_DESTROY_NONEXISTENT_WINDOW
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_NO_PRAGMA_WARNINGS
#define STRICT
#define VC_EXTRA_LEAN
#define WIN32_LEAN_AND_MEAN

#if _DEBUG
#	define _CRTDBG_MAP_ALLOC
#endif

#include "targetver.h"

// C runtime library memory management debugging support
#if _DEBUG
#	include <cerrno>
#	include <cstdlib>

#	include <malloc.h>
#	include <crtdbg.h>

#	include <new>
#	include <new.h>
#endif

// C standard library

#include <cstdio>
#include <cwchar>

// C++ standard template library

#pragma warning( push )
#pragma warning( disable: 4986 ) // 'function': exception specification does not match previous declaration
#	include <string>
#pragma warning( pop )
#include <vector>

// Project resource definitions
#include "resource.h"

// Active Template Library
#pragma warning( push )
#pragma warning( disable: 4191 ) // 'operator/operation' : unsafe conversion from 'type of expression' to 'type required'
#pragma warning( disable: 4263 ) // 'function' : member function does not override any base class virtual member function
#pragma warning( disable: 4264 ) // 'virtual_function' : no override available for virtual member function from base 'class'; function is hidden
#pragma warning( disable: 4265 ) // 'class' : class has virtual functions, but destructor is not virtual
#pragma warning( disable: 4365 ) // 'action' : conversion from 'type_1' to 'type_2', signed/unsigned mismatch
#pragma warning( disable: 4619 ) // #pragma warning : there is no warning number 'number'
#pragma warning( disable: 4946 ) // reinterpret_cast used between related classes: 'class1' and 'class2'
#pragma warning( disable: 4987 ) // nonstandard extension used: enum 'enum' used in qualified name
#	include <atlbase.h>
#	include <atlcom.h>
#	include <atlctl.h>
#pragma warning( pop )

// Windows SDK
#include <process.h>

// Windows DDK
extern "C" {
#	include <hidsdi.h>
};

using namespace ATL;
using namespace std;

// Project headers: wizard- or automatically-generated COM stuff
#include "PanicButton_i.h"
#include "dllmain.h"

// Project headers: infrastructure
#include "Debug.h"

// Project headers: implementation
#include "BigRedButton.h"

// Coclass Zive.PanicButton
#include "DPanicButtonEvents_CP.h"
#include "PanicButton.h"

#undef ZeroMemory

template<typename T> inline void ZeroMemory( T& t ) {
	RtlZeroMemory( &t, sizeof( T ) );
}

template<typename T> inline void ZeroMemory( T* t ) {
	RtlZeroMemory( t, sizeof( T ) );
}

template<typename T> inline void ZeroMemory( T* t, const size_t size ) {
	RtlZeroMemory( t, size );
}

inline void BreakIfDebuggerPresent( void ) {
	if ( IsDebuggerPresent( ) ) {
		DebugBreak( );
	}
}

inline void CloseHandleIfNotEqual( HANDLE& toClose, HANDLE value ) {
	if ( toClose != value ) {
		CloseHandle( toClose );
		toClose = value;
	}
}
